package com.arron.command;

public class Client {
    public static void main(String[] args) {
        //使用命令模式，完成通过遥控器，对电灯操作
        //创建电灯 的对象（接收者）
        LightReceiver receiver =new LightReceiver();
        //创建电灯 相关的开关命令
        LightOnCommand lightOnCommand =new LightOnCommand(receiver);
        LightOffCommand lightOffCommand = new LightOffCommand(receiver);
        System.out.println("==============使用遥控器操作电灯==============");
        //需要遥控器
        RemoteController remoteController = new RemoteController();
        //给遥控器设置命令 no= 0 是电灯 的开和关的操作
        remoteController.setCommand(0,lightOnCommand,lightOffCommand);
        System.out.println("--------按下电灯开的按钮--------");
        remoteController.onButtonWasPushed(0);
        System.out.println("--------按下电灯关的按钮--------");
        remoteController.offButtonWasPushed(0);
        System.out.println("--------按下电灯撤销按钮--------");
        remoteController.undoButtonWasPushed();

        System.out.println("==============使用遥控器操作电视==============");
        //创建电视的对象（接收者）
        TVReceiver tvReceiver =new TVReceiver();
        //创建电视相关的开关命令
        TVOnCommand tvOnCommand = new TVOnCommand(tvReceiver);
        TVOffCommand tvOffCommand = new TVOffCommand(tvReceiver);

        //给遥控器设置命令 no= 1 是电视 的开和关的操作
        remoteController.setCommand(1,tvOnCommand,tvOffCommand);
        System.out.println("--------按下电视开的按钮--------");
        remoteController.onButtonWasPushed(1);
        System.out.println("--------按下电视关的按钮--------");
        remoteController.offButtonWasPushed(1);
        System.out.println("--------按下电视撤销按钮--------");
        remoteController.undoButtonWasPushed();

    }
}
